<div id="main_organizations" class="span-24 last main">
    <div class="span-18">
        <div class="section_organizations_ads">
            <h2><?=$this->translate('Organizations and Campaigns'); ?></h2>
        
            <?
            if (count ( $this->mensajes ) > 0) {
                echo '<div class="success"><h2>';
                foreach ( $this->mensajes as $msg ) {
                    echo $msg . '<br>';
                }
                echo '</h2></div>'; 
            }
            ?>
                  
            <?php if ($this->ad): ?>

                   <?php
                   $auth = Zend_Auth::getInstance ();

                   foreach ($this->paginator as $key => $val): ?>
                    <div class="ad_excerpt">
                    
                      <?php
                          if ($val['photo'] !== null){
                              echo '<div class="ad_list_image">
                                <a href="/'.$this->lang.'/ad/org/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                              <img alt="'.$this->escape($val['title']).'" src="/images/uploads/ads/100/'.
                              $this->escape($val['photo']).'" /></a></div>';
                          } else {
                              echo '<div class="ad_list_image">';                 
                              if ($this->lang == 'es') {
                                  echo '<a href="/'.$this->lang.'/ad/org/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                                <img alt="'.$this->escape($val['title']).'" src="/images/sin_imagen.jpg" /></a></div>';
                              } else {
                                  echo '<a href="/'.$this->lang.'/ad/org/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                                <img alt="'.$this->escape($val['title']).'" src="/images/no_image.jpg" /></a></div>';
                              }
                             }
                       ?>
                    
                     <?php
                     $auth = Zend_Auth::getInstance ();
                     if ($auth->hasIdentity()):
                             if ( ($val['user_owner'] == $auth->getIdentity()->id)  || ($this->userRole == 1) ): ?>
                              <div>
                                  <a class="ads_section" href="/<?=$this->lang ?>/ad/orgedit/id/<?=$val['id'] ?>">
                                <?=$this->translate('Edit this ad') ?></a>
                              </div><br />
                     <?php endif;endif; ?>
                      
                      <div class="ad_excerpt_title">
                        <a class="ad_title_link" href="/<?=$this->lang ?>/ad/org/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title']) ?>"><?=$this->escape($val['title']) ?></a>
                      </div>
                      <span class="ad_url"><?=$this->translate('Website').':&nbsp;'?>
                        <a class="ads_section" target="_blank" href="<?=$val['url'] ?>"><?=$val['url'] ?></a>
                      </span>
                       <span class="ad_date"><?=$this->translate('Posted on '). $this->escape(date( $this->translate('l dS \o\f F Y H:i:s'), strtotime($val['date_created']))) ?><?=$this->translate('by user ') ?>
                        <a class="ads_section" href="/<?=$this->lang ?>/ad/listorg/id/<?=$val['user_owner'] ?>"><?=$this->escape($val['username']) ?></a>
                       </span>                                              
                       <div class="ad_body"><p><?php echo  $val['body']  ?></p></div>
                       <div class="ad_meta_info">
                                <div class="send_message">
                                    <a rel="nofollow" class="ads_section" href="/<?=$this->lang ?>/message/create/id_user_to/<?=$val['user_owner'].'/subject/'.$this->escape($val['title'])
                                    ?>">+ <?=$this->translate('Send message to the owner') ?></a></b>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="ads_section" href="/<?=$this->lang ?>/ad/org/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title'])
                                    ?>">+ <?=$this->translate('Write a new comment') ?></a></div>
                        
                                  <?php if ($val['readings_count']): ?>
                                      <div class="readings_count"><?=$val['readings_count'] . '&nbsp;&nbsp;' .$this->translate('readings') ?></div>
                                  <?php endif;?>
                        
                                  <?php if ($val['comments_count']): ?>
                                      <div class="comments_count"><?=', '.$this->escape( $val['comments_count'] == null  ? 0 : $val['comments_count'] ).' '.$this->translate('comments') ?></div>
                                  <?php endif;?>
                           </div>
                        </div>
                        
                        <?php endforeach; ?>
    
                <?php else: ?>
                
                    <div class="no_results">
                      <div class="no_results_txt_strong"><?=$this->translate ( 'No ads to display for this location.');?></div>
                    </div>
                
                <?php endif;?>
    
            <?php echo $this->paginationControl($this->paginator,
                                                'Sliding',
                                                'partials/paginator_ads.phtml'); ?>

            </div> <!-- /div ads -->
        </div>

        <div class="span-6 last">
            <div class="advertising">
                <a href="/<?=$this->lang ?>/page/organizations">
                <img alt="<?=$this->translate('Organizations and Campaigns') ?>" src="/images/organizations_banner.png" />
                </a>
            </div>
            <div class="clearer"></div>
            <?php  
            if ( $this->userRole == 1  || $this->userRole == 2 ): ?>
                    <div class="new_ad_icon">
                        <a class="new_ad" href="/<?=$this->lang ?>/ad/orgcreate">
                            <img alt="<?=$this->translate('Create new ad') ?>" src="/images/icons/ico_new_ad.png" class="valign" /><div class="txt_valign"><?=$this->translate('Create new ad') ?></div></a>
                    </div> 
                    <div class="clearer"></div>
             <?php endif;?>  
            <div class="advertising">
                <!-- BEGIN PARTNER PROGRAM - DO NOT CHANGE THE PARAMETERS OF THE HYPERLINK -->
				<script language="javascript" type="text/javascript" src="http://program.epartner.es/view.asp?ref=570686&site=8346&type=html&hnb=5&js=1"></script>
				<noscript><a href="http://web.epartner.es/click.asp?ref=570686&site=8346&type=b1&bnb=1" target="_blank">
				<img src="http://program.epartner.es/view.asp?ref=570686&site=8346&b=1" border="0"/></a><br /></noscript>
				<!-- END PARTNER PROGRAM -->
            </div>
        </div>

</div> <!-- /main -->
